<?php

    /*
    Fecha Cambio: 23/02/2015
    Desarrollador: Miguel Angel Ospina Sanchez
    Objetivo: Se anexa a la consulta el campo de observaciones donde el medico hace una descripcion
              al momento de hacer una solicitud de una unidad de transfusion.         
    */

    include_once '../../../../controlador/php/conexion/Conexion10.php';
    $con = new Conexion10();

    $ingreso = $_REQUEST['ingreso'];
    
    $soli = "SELECT AINCONSEC, PACNUMDOC, HCNUMFOL, HCMTRANSF.HCCM05N01 AS Fecha_Solicitud,
             CASE WHEN HCMTRANSF.HCCM02N15 = '' THEN '-' ELSE CONVERT(NVARCHAR(100),HCMTRANSF.HCCM02N15)END AS Sangre_Total,
             CASE WHEN HCMTRANSF.HCCM02N16='' THEN '-' ELSE CONVERT(NVARCHAR(100),HCMTRANSF.HCCM02N16)END AS Concentrado_Globular, 
             CASE WHEN HCMTRANSF.HCCM02N17='' THEN '-' ELSE CONVERT(NVARCHAR(100),HCMTRANSF.HCCM02N17)END AS Plasma_Fresco_Congelado,
             CASE WHEN HCMTRANSF.HCCM02N18='' THEN '-' ELSE CONVERT(NVARCHAR(100),HCMTRANSF.HCCM02N18)END AS Plaquetas_Manuales, 
             CASE WHEN HCMTRANSF.HCCM02N19=''THEN '-' ELSE CONVERT(NVARCHAR(100),HCMTRANSF.HCCM02N19) END AS Plaquetas_Por_Aferesis, 
             CASE WHEN HCMTRANSF.HCCM02N20='' THEN '-'ELSE CONVERT(NVARCHAR(100),HCMTRANSF.HCCM02N20)END As Crioprecitiado,
             case when HCCM07N29 IS null then 'No'else 'Si' end as 'Reserva',
             cast(HCCM02N16 as text)as HCCM02N16,cast(HCCM02N21 as text) as HCCM02N21,cast(HCCM03N23 as text) as HCCM03N23,cast(HCCM03N37 as text) as HCCM03N37
             FROM HCNFOLIO
             INNER JOIN HCMTRANSF ON HCMTRANSF.HCNFOLIO = HCNFOLIO.OID
             INNER JOIN GENPACIEN ON HCNFOLIO.GENPACIEN = GENPACIEN.OID 
             INNER JOIN ADNINGRESO ON HCNFOLIO.ADNINGRESO = ADNINGRESO.OID AND ADNINGRESO.GENPACIEN = GENPACIEN.OID
             WHERE AINCONSEC= '".$ingreso."'
             ORDER BY HCNFOLIO.GENPACIEN";
    $lstm = $con->query($soli);
    
    while($lstm2 = mssql_fetch_array($lstm)){
        $lst[] = array_map('utf8_encode',$lstm2);
    }
    
    $con->cerrarConexion();
    print_r(json_encode($lst));
?>
